#! /usr/bin/python3
# -*- coding: UTF-8 -*-

if __name__ == "__main__":
	raise Exception("不支持从这里调用")

__version__ = "1.0"
__all__ = ["CheckTokenRpcFunc"]

from com.mousechsh.business.app.order.err.MouseChshLogicErrMsg import MouseChshLogicErrMsg
from com.mousechsh.business.app.order.rpc.CheckTokenRpcException import CheckTokenNeedTokenRpcException

from com.mousechsh.common.io.cache.MouseChshRedisCache import MouseChshRedisCache
from com.mousechsh.common.middle.rpc.MouseChshRpcExceptions import MouseChshRpcRequestNoDataException
from com.mousechsh.common.middle.rpc.MouseChshRpcFunc import mousechsh_rpc_func_annotation


@mousechsh_rpc_func_annotation(name='CheckToken')
def CheckTokenRpcFunc(dict):
	data = dict.get('data', None)
	if data is None:
		raise MouseChshRpcRequestNoDataException()
	token = data.get('token', None)
	if token is None:
		raise CheckTokenNeedTokenRpcException()
	cache = MouseChshRedisCache()
	tt = cache.get('Login-' + token)
	return {
		'code': MouseChshLogicErrMsg.CheckTokenOK.value,
		'message': MouseChshLogicErrMsg.text(MouseChshLogicErrMsg.CheckTokenOK),
		'data': {
			'valid': 1
		}
	}
